<?php

namespace App\Http\Controllers;

use App\Services\AqService;
use Illuminate\Http\Request;
use Ninex\Lib\Http\Controllers\LibController;

class AqController extends LibController
{
    public $service;
    public function __construct(Request $request,AqService $service)
    {
        parent::__construct($request);
        $this->service = $service;
    }

    public function modelList()
	{
		return $this->success($this->service->modelList(),'获取成功',200);
	}

	public function initData()
	{
		return $this->success($this->service->initData(),'初始化成功',200);
	}

	public function initShare()
	{
		return $this->success($this->service->initShare(),'微信分享初始化成功',200);
	}

	public function sendChat()
	{
		$this->service->sendChat();
	}

	public function sessionList()
	{
		return $this->success($this->service->sessionList(),'获取成功',200);
	}

	public function updateSession()
	{
		return $this->success($this->service->updateSession(),'更新成功',200);
	}

	public function deleteSession($id)
	{
		return $this->success($this->service->deleteSession($id),'删除成功',200);
	}

	public function messageList()
	{
		$this->request->validate([
			'sessionId' => 'required'
		]);
		return $this->success($this->service->messageList(),'获取成功',200);
	}

	public function rateChat()
	{
		$this->request->validate([
			'id' => 'required',
			'rate' => 'required|decimal:0,5'
		]);
		return $this->success($this->service->rateChat(),'评分成功',200);
	}

	public function getFiles()
	{
		return $this->success($this->service->getFiles(),'获取成功',200);
	}

	public function sessionInfo($id)
	{
		return $this->success($this->service->sessionInfo($id),'获取成功',200);
	}

	public function createSession()
	{
		$this->request->validate([
			'modelId' => 'required',
			'sessionTitle' => 'required'
		]);
		return $this->success($this->service->createSession(),'创建成功',200);
	}

	public function clearSession($modelId)
	{
		return $this->success($this->service->clearSession($modelId),'清空成功',200);
	}
	public function uploadFile()
	{
		return $this->success($this->service->uploadFile(),'上传成功',200);
	}

	public function download($id)
	{
		return $this->service->download($id);
	}

	public function getTool($id)
	{
		return $this->success($this->service->getTool($id),'获取成功',200);
	}

	public function getToolMessage($id)
	{
		return $this->success($this->service->getToolMessage($id),'获取成功',200);
	}

	public function device()
	{
		return $this->service->getDevice();
	}
}
